package com.wallet.crypto.trustapp.ui.setting;

import android.content.Intent;
import android.os.Bundle;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.widget.ImageView;

import com.wallet.crypto.trustapp.R;
import com.wallet.crypto.trustapp.ui.BaseActivity;
import com.wallet.crypto.trustapp.ui.widget.adapter.SettingAdapter;
import com.wallet.crypto.trustapp.ui.widget.entity.SettingItem;
import com.wallet.crypto.trustapp.widget.SpacesItemDecoration;

import java.util.ArrayList;

public class SettingActivity extends BaseActivity {

    private static final int[] ICON_ITEM_HEADER = {
            R.mipmap.qr_code_icon,
            R.mipmap.qr_code_icon,
            R.mipmap.qr_code_icon,
            R.mipmap.qr_code_icon,
            R.mipmap.qr_code_icon
    };

    private static final int[] ITEM_TITLE = {
            R.string.s0001,
            R.string.s0002,
            R.string.s0003,
            R.string.s0004,
            R.string.s0005
    };

    private final ArrayList<SettingItem> mItems = new ArrayList<>();

    private ImageView mClose;
    private RecyclerView mRecyclerView;
    private SettingAdapter mAdapter;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_settings);
        initView();
    }

    private void initView() {
        mClose = findViewById(R.id.top_icon);
        mRecyclerView = findViewById(R.id.setting_rev);
        mRecyclerView.setLayoutManager(new LinearLayoutManager(this));
        mRecyclerView.addItemDecoration(new SpacesItemDecoration(10));
        initData();
        mAdapter = new SettingAdapter(this, mItems);
        mRecyclerView.setAdapter(mAdapter);
        mAdapter.setmOnItemClickListener((view, position) -> {
            Intent intent = null;
            switch (position) {
                case 0:
                    intent = new Intent(this, IndicatesSettingActivity.class);
                    startActivity(intent);
                    break;

                case 1:
                    intent = new Intent(this, ChangeNameActivity.class);
                    startActivity(intent);
                    break;

                case 2:
                    intent = new Intent(this, SecuritySettingActivity.class);
                    startActivity(intent);
                    break;

                case 3:
                    break;
                case 4:

                    break;
                case 5:
                    intent = new Intent(this, SettingPeakActivity.class);
                    startActivity(intent);
                    break;


            }
        });
        mClose.setOnClickListener(this::OnCloseListener);
    }

    private void OnCloseListener(View view) {
        finish();
    }

    private void initData() {
        mItems.add(new SettingItem(ICON_ITEM_HEADER[0], ITEM_TITLE[0], false));
        mItems.add(new SettingItem(ICON_ITEM_HEADER[1], ITEM_TITLE[1], false));
        mItems.add(new SettingItem(ICON_ITEM_HEADER[2], ITEM_TITLE[2], false));
        mItems.add(new SettingItem(0, 0, true));
        mItems.add(new SettingItem(ICON_ITEM_HEADER[3], ITEM_TITLE[3], false));
        mItems.add(new SettingItem(ICON_ITEM_HEADER[4], ITEM_TITLE[4], false));
    }

}
